using FluentNHibernate;
using FluentNHibernate.AutoMap;
using FluentNHibernate.Mapping;
using Webshop20.Domain.Catalog.Core;
using Webshop20.Domain.Common;
using Webshop20.Infrastructure.Persistence.NH.AutoMappings.Conventions.Common;
using Webshop20.Infrastructure.Persistence.NH.AutoMappings.Overrides;


namespace Webshop20.Infrastructure.Persistence.NH.AutoMappings
{
    public class ForCatalog
    {
        public static AutoPersistenceModel GetPersistenceModel()
        {

            return
                AutoPersistenceModel.MapEntitiesFromAssemblyOf<ShoppingCart>()
                    .Where(x => x.Namespace == "Webshop20.Domain.Catalog.Core")

                    .WithSetup(
                                convention =>
                                {
                                    convention.IsBaseType = bt => bt == typeof(Entity) || bt == typeof(Item);
                                    

                                    
                                }
                                    )
                    .ConventionDiscovery.AddFromAssemblyOf<IdConvention>()
                    .UseOverridesFromAssemblyOf<VisitorOverride>()
                //.ConventionDiscovery.Setup(c=>c.Add<IdConvention>())
                   ;
            
        }
    }
}